package com.zan.pattern.command;

import java.util.Map;
import java.util.Set;

/**
 * @Author Zan
 * @Create 2024/4/27 9:57
 * @Description : 具体命令类
 * @ClassName: OrderCommand
 */
public class OrderCommand implements Command {

    // 持有接收者对象
    private SeniorChef receiver;

    // 持有订单对象
    private Order order;

    public OrderCommand(SeniorChef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable() + "桌的订单：");
        // 需要让厨师去做订单的商品
        Map<String, Integer> food = order.getFood();
        // 遍历map集合
        Set<String> keys = food.keySet();
        for (String key : keys) {
            receiver.makeFood(key, food.get(key));
        }

        System.out.println(order.getDiningTable() + "桌的饭准备完毕！！！");
    }
}
